"""
example09 - JSON格式的字符串

操作系统：Windows、iOS、Android、macOS、Linux、Unix
编程语言：Python、Java、PHP、Go、C++

1、两个异构的系统之间交换数据最好的选择是交换纯文本（可以屏蔽系统和编程语言的差异）
2、纯文本应该是结构化或半结构化的纯文本（有一定的格式）
    - XML ---> eXtensible Markup Language ---> 可扩展标记语言
    - JSON ---> JavaScript Object Notation ---> 大多数网站和数据接口服务使用的数据格式
    - YAML ---> Yet Another Markup Lamgt
3、如何将JSON更是转换成Python程序中的字典？
    ---> json 模块 ---> loads 函数

URL ---> Universal Resource Locator ---> 统一资源定位符

Author: Administrator
Date: 2024/1/17
"""

import json

data = """{
    "code": 200,
    "msg": "ok",
    "data": {
        "current_page": 1,
        "data": [
            {
                "id": 13713,
                "company_id": 29,
                "image": "\/storage\/images\/100x100\/66eea1406d262a60bb2a08c4ae355481.jpg",
                "sku": "AKZACB0205",
                "spu": "AKZACB02",
                "name_cn": "\u8fd0\u52a8\u6c34\u888b\u80cc\u5305\uff08\u9ed1\u7eff\uff09",
                "default_supply_id": 3209,
                "price": "50.3000",
                "status": "\u65b0\u54c1",
                "weight": "0.4000",
                "weight_unit": 2,
                "logistics_attr_ids": "28",
                "length": 25,
                "width": 23,
                "height": 5,
                "length_unit": 1,
                "qc_type": "\u514d\u68c0",
                "is_composite_product": 1,
                "purchaser_user_id": 220,
                "product_user_id": 371,
                "dev_user_id": 371,
                "department_id": 22,
                "default_supply_moq": 500,
                "default_supply_delivery_days": 30,
                "created_at": "2024-01-16 10:58:40",
                "updated_at": "2024-01-16 11:12:55",
                "is_supply_assemble": "\u662f",
                "category_id": 146,
                "brand_id": 4,
                "is_seasonal": 0,
                "seasonal_time": "\u5426",
                "plan_period": 0,
                "classification": "\u65b0\u54c1\u7c7b",
                "term_of_validity": 0,
                "is_original_box_shipment": "\u662f",
                "global_is_use_open": "\u5426",
                "is_check": 1,
                "is_sub_product": 0,
                "weight_unit_title": "kg",
                "length_unit_title": "cm",
                "supply_purchase_price": "50.3000",
                "logistics_attrs": "\u670d\u88c5\u7c7b\u7eba\u7ec7",
                "company_name": "\u5965\u76db\u8fbe",
                "big_image": "\/storage\/images\/product\/66eea1406d262a60bb2a08c4ae355481.jpg",
                "short_name_cn": "\u8fd0\u52a8\u6c34\u888b\u80cc\u5305\uff08\u9ed1...",
                "hs_code": "",
                "stock": 0,
                "size": "25 * 23 * 5",
                "default_supply": "\u6cc9\u5dde\u9177\u7c73\u5a74\u513f\u7528\u54c1\u6709\u9650\u516c\u53f8",
                "moq": 1000,
                "dev_user": "\u82cf\u6d0b \u9a91\u5f00\u53d1\u4e13\u54581",
                "product_user": "\u82cf\u6d0b \u9a91\u5f00\u53d1\u4e13\u54581",
                "purchaser_user": "\u6c88\u69ff\u4e1c",
                "throwing_weight": "0.5227",
                "volume_weight": "0.5750",
                "ave_price": "50.3000",
                "category_name": "\u9a91\u884c\u7528\u54c1",
                "brand_name": "ZA",
                "department_name": "\u9a91\u884c\u4e1a\u52a1\u7ec4",
                "gross_weight": "17.0000"
            },
            {
                "id": 13709,
                "company_id": 29,
                "image": "\/storage\/images\/100x100\/3cd4fab4bb75c7eddd8a5d1273972f7d.jpg",
                "sku": "AKZACB0205-2-2",
                "spu": "AKZACB02",
                "name_cn": "\u8865\u6c34\u888b",
                "default_supply_id": 4797,
                "price": "23.8000",
                "status": "\u65b0\u54c1",
                "weight": "0.1750",
                "weight_unit": 2,
                "logistics_attr_ids": "1",
                "length": 35.1,
                "width": 17.5,
                "height": 2,
                "length_unit": 1,
                "qc_type": "\u514d\u68c0",
                "is_composite_product": 0,
                "purchaser_user_id": 220,
                "product_user_id": 371,
                "dev_user_id": 371,
                "department_id": 22,
                "default_supply_moq": 200,
                "default_supply_delivery_days": 20,
                "created_at": "2024-01-16 10:39:15",
                "updated_at": "2024-01-16 11:12:55",
                "is_supply_assemble": "\u672a\u77e5",
                "category_id": 146,
                "brand_id": 4,
                "is_seasonal": 0,
                "seasonal_time": "\u5426",
                "plan_period": 0,
                "classification": "\u65b0\u54c1\u7c7b",
                "term_of_validity": 0,
                "is_original_box_shipment": "\u662f",
                "global_is_use_open": "\u5426",
                "is_check": 2,
                "is_sub_product": 1,
                "weight_unit_title": "kg",
                "length_unit_title": "cm",
                "supply_purchase_price": "23.8000",
                "logistics_attrs": "\u666e\u8d27",
                "company_name": "\u5965\u76db\u8fbe",
                "big_image": "\/storage\/images\/product\/3cd4fab4bb75c7eddd8a5d1273972f7d.jpg",
                "short_name_cn": "\u8865\u6c34\u888b",
                "hs_code": "",
                "stock": 0,
                "size": "35.1 * 17.5 * 2",
                "default_supply": "\u4e2d\u5c71\u5e02\u7f8e\u9014\u6237\u5916\u7528\u54c1\u6709\u9650\u516c\u53f8",
                "moq": 500,
                "dev_user": "\u82cf\u6d0b \u9a91\u5f00\u53d1\u4e13\u54581",
                "product_user": "\u82cf\u6d0b \u9a91\u5f00\u53d1\u4e13\u54581",
                "purchaser_user": "\u6c88\u69ff\u4e1c",
                "throwing_weight": "0.2234",
                "volume_weight": "0.2457",
                "ave_price": "23.8000",
                "category_name": "\u9a91\u884c\u7528\u54c1",
                "brand_name": "ZA",
                "department_name": "\u9a91\u884c\u4e1a\u52a1\u7ec4",
                "gross_weight": "20.0000"
            },
            {
                "id": 13706,
                "company_id": 29,
                "image": "\/storage\/images\/100x100\/c7a7f3c62b4a8bf51ad8c637f4a12022.jpg",
                "sku": "AKZACB0205-2-1",
                "spu": "AKZACB02",
                "name_cn": "\u6c34\u888b\u80cc\u5305\uff08\u9ed1\u7eff\uff09",
                "default_supply_id": 3209,
                "price": "26.5000",
                "status": "\u65b0\u54c1",
                "weight": "0.2400",
                "weight_unit": 2,
                "logistics_attr_ids": "28",
                "length": 25,
                "width": 23,
                "height": 5,
                "length_unit": 1,
                "qc_type": "\u514d\u68c0",
                "is_composite_product": 0,
                "purchaser_user_id": 220,
                "product_user_id": 371,
                "dev_user_id": 371,
                "department_id": 22,
                "default_supply_moq": 500,
                "default_supply_delivery_days": 30,
                "created_at": "2024-01-16 10:27:10",
                "updated_at": "2024-01-16 11:12:55",
                "is_supply_assemble": "\u672a\u77e5",
                "category_id": 146,
                "brand_id": 4,
                "is_seasonal": 0,
                "seasonal_time": "\u5426",
                "plan_period": 0,
                "classification": "\u65b0\u54c1\u7c7b",
                "term_of_validity": 0,
                "is_original_box_shipment": "\u662f",
                "global_is_use_open": "\u5426",
                "is_check": 2,
                "is_sub_product": 1,
                "weight_unit_title": "kg",
                "length_unit_title": "cm",
                "supply_purchase_price": "26.5000",
                "logistics_attrs": "\u670d\u88c5\u7c7b\u7eba\u7ec7",
                "company_name": "\u5965\u76db\u8fbe",
                "big_image": "\/storage\/images\/product\/c7a7f3c62b4a8bf51ad8c637f4a12022.jpg",
                "short_name_cn": "\u6c34\u888b\u80cc\u5305\uff08\u9ed1\u7eff\uff09",
                "hs_code": "",
                "stock": 0,
                "size": "25 * 23 * 5",
                "default_supply": "\u6cc9\u5dde\u9177\u7c73\u5a74\u513f\u7528\u54c1\u6709\u9650\u516c\u53f8",
                "moq": 1000,
                "dev_user": "\u82cf\u6d0b \u9a91\u5f00\u53d1\u4e13\u54581",
                "product_user": "\u82cf\u6d0b \u9a91\u5f00\u53d1\u4e13\u54581",
                "purchaser_user": "\u6c88\u69ff\u4e1c",
                "throwing_weight": "0.5227",
                "volume_weight": "0.5750",
                "ave_price": "26.5000",
                "category_name": "\u9a91\u884c\u7528\u54c1",
                "brand_name": "ZA",
                "department_name": "\u9a91\u884c\u4e1a\u52a1\u7ec4",
                "gross_weight": "17.0000"
            }
        ],
        "first_page_url": "http:\/\/www.mosserp.com\/admin\/product_list?page=1",
        "from": 1,
        "last_page": 1,
        "last_page_url": "http:\/\/www.mosserp.com\/admin\/product_list?page=1",
        "next_page_url": null,
        "path": "http:\/\/www.mosserp.com\/admin\/product_list",
        "per_page": "20",
        "prev_page_url": null,
        "to": 3,
        "total": 3
    }
}"""

# loads函数可以将JSON格式的数据转换成O
news_dict = json.loads(data)
news_list = news_dict['data']['data']
for news in news_list:
    print(news['sku'])
    print(news['name_cn'])